/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.OutTransCodeDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.OutTransCodeDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.OutTransCodeDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_out_trans_code.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisOutTransCodeDAO extends SqlMapClientDaoSupport implements OutTransCodeDAO {

    /**
     *  Query DB table <tt>sgw_out_trans_code</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, out_trans_code_name, out_trans_code, channel_system_id, out_router_type, memo, gmt_create, gmt_modified from sgw_out_trans_code</tt>
     *
     *	@return List<OutTransCodeDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<OutTransCodeDO> loadAll() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-OUT-TRANS-CODE-LOAD-ALL", null);

    }

    /**
     *  Insert one <tt>OutTransCodeDO</tt> object to DB table <tt>sgw_out_trans_code</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_out_trans_code(id,out_trans_code_name,out_trans_code,channel_system_id,out_router_type,memo,gmt_create,gmt_modified) values (?, ?, ?, ?, ?, ?, sysdate, sysdate)</tt>
     *
     *	@param outTransCode
     *	@return String
     *	@throws DataAccessException
     */
    public String insert(OutTransCodeDO outTransCode) throws DataAccessException {
        if (outTransCode == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-OUT-TRANS-CODE-INSERT", outTransCode);

        return outTransCode.getId();
    }

    /**
     *  Update DB table <tt>sgw_out_trans_code</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_out_trans_code set out_trans_code_name=?, out_trans_code=?, channel_system_id=?, out_router_type=?, memo=?, gmt_modified=sysdate where (id = ?)</tt>
     *
     *	@param outTransCodeName
     *	@param outTransCode
     *	@param channelSystemId
     *	@param outRouterType
     *	@param memo
     *	@param id
     *  @param financeExchangeCode
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public int update(String outTransCodeName, String outTransCode, String channelSystemId,
                      String outRouterType, String memo, String id, String financeExchangeCode)
                                                                                               throws DataAccessException {
        Map param = new HashMap();

        param.put("outTransCodeName", outTransCodeName);
        param.put("outTransCode", outTransCode);
        param.put("channelSystemId", channelSystemId);
        param.put("outRouterType", outRouterType);
        param.put("memo", memo);
        param.put("id", id);
        param.put("financeExchangeCode", financeExchangeCode);

        return getSqlMapClientTemplate().update("MS-OUT-TRANS-CODE-UPDATE", param);
    }

    /**
     *  Query DB table <tt>sgw_out_trans_code</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, out_trans_code_name, out_trans_code, channel_system_id, out_router_type, memo, gmt_create, gmt_modified from sgw_out_trans_code where ((id = ?) AND (out_trans_code = ?) AND (channel_system_id = ?) AND (out_router_type = ?))</tt>
     *
     *	@param id
     *	@param outTransCode
     *	@param channelSystemId
     *	@param outRouterType
     *	@return List<OutTransCodeDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public List<OutTransCodeDO> select(String id, String outTransCode, String channelSystemId,
                                       String outRouterType) throws DataAccessException {
        Map param = new HashMap();

        param.put("id", id);
        param.put("outTransCode", outTransCode);
        param.put("channelSystemId", channelSystemId);
        param.put("outRouterType", outRouterType);

        return getSqlMapClientTemplate().queryForList("MS-OUT-TRANS-CODE-SELECT", param);

    }

    /**
     *  Query DB table <tt>sgw_out_trans_code</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, out_trans_code_name, out_trans_code, channel_system_id, out_router_type, memo, gmt_create, gmt_modified from sgw_out_trans_code where ((out_trans_code = ?) AND (channel_system_id = ?))</tt>
     *
     *	@param outTransCode
     *	@param channelSystemId
     *	@return OutTransCodeDO
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public OutTransCodeDO selectByOutTransCodeAndChannelSystem(String outTransCode,
                                                               String channelSystemId)
                                                                                      throws DataAccessException {
        Map param = new HashMap();

        param.put("outTransCode", outTransCode);
        param.put("channelSystemId", channelSystemId);

        return (OutTransCodeDO) getSqlMapClientTemplate().queryForObject(
            "MS-OUT-TRANS-CODE-SELECT-BY-OUT-TRANS-CODE-AND-CHANNEL-SYSTEM", param);

    }

    /**
     *  Query DB table <tt>sgw_out_trans_code</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, out_trans_code_name, out_trans_code, channel_system_id, out_router_type, memo, gmt_create, gmt_modified from sgw_out_trans_code where (id = ?)</tt>
     *
     *	@param id
     *	@return OutTransCodeDO
     *	@throws DataAccessException
     */
    public OutTransCodeDO selectById(String id) throws DataAccessException {

        return (OutTransCodeDO) getSqlMapClientTemplate().queryForObject(
            "MS-OUT-TRANS-CODE-SELECT-BY-ID", id);

    }

    /**
     *  Delete records from DB table <tt>sgw_out_trans_code</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_out_trans_code where (id = ?)</tt>
     *
     *	@param id
     *	@return int
     *	@throws DataAccessException
     */
    public int delete(String id) throws DataAccessException {

        return getSqlMapClientTemplate().delete("MS-OUT-TRANS-CODE-DELETE", id);
    }

}